var app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    amount: '', //总金额
    purchaseWeight: '',//今日收货量
    purchasePrice: '',//今日收货金额
    saleWeight: '',//今日销货量
    salePrice: ''//今日销货金额
  },
  //提现
  gomoney: function () {
    var that = this
    wx.navigateTo({
      url: '/pages/mine/myBalance'
    })
  },
  // //充值
  pushmoney: function () {
    var that = this
    wx.navigateTo({
      url: '/pages/mine/paymentCard'
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.showLoading({ title: '加载中' })
    var that = this;
    wx.request({
      method: 'POST',
      url: app.preUrl + 'accountInfo',
      dataType: 'json',
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      data: {
        userId: app.globalData.userId
      },
      success: function (res) {
        console.log(res)
        wx.hideLoading();
        if (res.data.code == 100) {
          that.setData({ amount: res.data.result.amount });
        }
      },
      fail: function (error) {
        console.log(error);
      }
    })
    wx.request({
      method: 'POST',
      url: app.preUrl + 'getTodayData',
      dataType: 'json',
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      data: {
        userId: app.globalData.userId
      },
      success: function (res) {
        console.log(res);
        wx.hideLoading();
        if (res.data.code == 100) {
          that.setData({ 
            purchaseWeight: res.data.result.purchaseWeight,
            purchasePrice: res.data.result.purchasePrice,
            saleWeight: res.data.result.saleWeight,
            salePrice: res.data.result.salePrice
           })
        }
      },
      fail: function (error) {
        console.log(error);
      }
    })
  },
  //收支记账
  goReceiptsBookkeeping: function () {
    wx.navigateTo({
      url: 'receiptsBookkeeping',
    })
  },
  //采购报表
  goPurchaseReport: function () {
    wx.navigateTo({
      url: 'purchaseReport',
    })
  },
  //销货报表
  goSalesReport: function () {
    wx.navigateTo({
      url: 'salesReport',
    })
  },
  //运营报表
  goProfitReport: function () {
    wx.navigateTo({
      url: 'profitReport',
    })
  },
  //库存报表
  goStoreStatistics:function(){
    wx.navigateTo({
      url: '../home/store_statistics',
    })
  },
  
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    
  }
})